<template>
  <div class="cg-from" :class="[ggclass]">
    <slot></slot>
  </div>
</template>

<script setup lang="ts">
import propsMixin from "../mixins/props/index.js";
import { defineProps, reactive, toRefs, provide } from "vue";
const props = defineProps({
  ...propsMixin.props,
  labelPosition: {
    //top 纵向排列，left ：横向排列
    type: String,
    default: "top",
  },
  ggclass: {
    type: String,
    default: "",
  },
  labelWidth: {
    type: String,
    default: "",
  },
  slotJc: {
    //插槽排列方式
    type: String,
    default: "flex-start",
  },
  textAlign: {
    //文字排列方式
    type: String,
    default: "",
  },
});

interface stateType {
  funList: Function[];
}
const state: stateType = reactive({
  funList: [],
});

const verify = () => {
  let num = 0;
  state.funList.forEach((v: Function) => {
    if (v()) {
      num++;
    }
  });
  return num === 0;
};
const pushInputVerify = (v: Function) => {
  state.funList.push(v);
};

provide("cForm", reactive({ ...props, verify, pushInputVerify }));
</script>

<style></style>